﻿String.prototype.format = function () {
    var arg = arguments;
    return this.replace(/\{(\d+)\}/g,
    function (m, i) {
        return arg[i]
    })
};
String.prototype.startWith = function (str) {
    var reg = new RegExp("^" + str);
    return reg.test(this)
};
String.prototype.endWith = function (str) {
    var reg = new RegExp(str + "$");
    return reg.test(this)
};
emptyFn = function () { };
var utils = {
    ns: function () {
        for (var i = 0; i < arguments.length; i++) {
            var d = arguments[i].split('.');
            var o = window;
            for (var j = 0; j < d.length; j++) {
                o[d[j]] = o[d[j]] || {};
                o = o[d[j]]
            }
        }
    },
    extend: function (sp, overrides) {
        var tmp = function () { };
        tmp.prototype = sp.prototype;
        var sb = function (options) {
            options = options || {};
            this.init(options)
        };
        sb.prototype = new tmp();
        sb.prototype.constructor = sb;
        jQuery.extend(sb.prototype, overrides);
        sb.prototype.base = sp.prototype;
        sb.extend = function (overrides) {
            return utils.extend(sb, overrides)
        };
        return sb
    },
    urlParam: function (url, name, value) {
        if (typeof value == 'undefined') {
            var reg = new RegExp('(?:\\\?|&)' + name + '=(?:[^&]*)', 'ig');
            var val = url.match(reg);
            if (val == null) return '';
            var rep = new RegExp('(?:\\\?|&)' + name + '=', 'i');
            for (var i = 0; i < val.length; i++) val[i] = val[i].replace(rep, '');
            return unescape(val.join())
        } else {
            var reg = new RegExp(name + '=(?:[^&]*)&*', 'ig');
            url = url.replace(reg, '');
            if (url.indexOf('?') == -1) url += '?';
            else if (!url.endWith('&')) url += '&';
            url += '{0}={1}'.format(name, encodeURIComponent(value));
            return url
        }
    },
    addFav: function (url, title) {
        try {
            external.addFavorite(url, title)
        } catch (e) {
            alert('加入收藏失败，请使用 Ctrl+D 进行添加。')
        }
    },
    toJsonString: function (obj) {
        if (obj === null) return '';
        var arr = [];
        var getJson = function (obj) {
            if (obj == null) {
                return 'null'
            }
            switch (obj.constructor) {
                case Array:
                    return '[' + utils.toJsonString(obj) + ']';
                case Object:
                    return utils.toJsonString(obj);
                case Number:
                    return obj;
                case String:
                    return '"' + obj.replace(/(\\|\")/g, "\\$1").replace(/\n|\r|\t/g,
                function () {
                    var a = arguments[0];
                    return (a == '\n') ? '\\n' : (a == '\r') ? '\\r' : (a == '\t') ? '\\t' : ""
                }) + '"';
                case Boolean:
                    return obj ? "true" : "false";
                case Date:
                    return '"\\\/Date(' + (obj - new Date(1970, 0, 1)) + ')\\\/"'
            }
        };
        for (var item in obj) {
            var vl = obj[item];
            if (vl && vl.constructor && (vl.constructor == Function)) continue;
            if (/\d+/.test(item)) arr.push(utils.toJsonString(vl));
            else arr.push('\"' + item + '\":' + getJson(vl))
        };
        if (obj.constructor == Object) return '{' + arr.join() + '}';
        else return arr.join()
    },
    copyToClipboard: function (text, callback) {
        if (window.clipboardData) {
            window.clipboardData.setData("Text", text);
            if (callback) callback()
        } else alert('您的浏览器不支持此功能，请手动复制地址栏的网址！')
    },
    cookie: function (name, value, options) {
        if (typeof value != 'undefined') {
            options = options || {};
            if (value == null) {
                value = '';
                options.expires = -1
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000))
                } else {
                    date = options.expires
                }
                expires = '; expires=' + date.toUTCString()
            }
            var path = options.path ? '; path=' + (options.path) : '';
            var domain = options.domain ? '; domain=' + (options.domain) : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain].join('')
        } else {
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++) {
                    var ck = $.trim(cookies[i]);
                    if (ck.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(ck.substring(name.length + 1));
                        break
                    }
                }
            }
            return cookieValue
        }
    },
    loadResource: function (type, urls, callback, scope) {
        type = type.toLowerCase();
        if (typeof urls == 'string') urls = [urls];
        switch (type) {
            case 'script':
                for (var i = 0; i < urls.length; i++) {
                    jQuery.get(urls[i],
                function (res) {
                    eval(res);
                    if (i == urls.length && callback) callback.call(scope || window)
                })
                }
                break;
            case 'css':
                for (var i = 0; i < urls.length; i++) {
                    var dom = document.createElement('link');
                    dom.rel = 'stylesheet';
                    dom.type = 'text/css';
                    dom.href = urls[i];
                    document.getElementsByTagName('head').item(0).appendChild(dom)
                }
                break
        }
    }
};
var ObjectBase = utils.extend(Object, {
    init: function (options, scope) {
        (function () {
            this.options = options
        }).call(scope || this);
        return this
    },
    regEvent: function () {
        var e = this.event = (this.event || []);
        var m = this.eventMapping = this.eventMapping || {};
        for (var i = 0; i < arguments.length; i++) {
            e.push(arguments[i]);
            m[arguments[i]] = []
        };
        return this
    },
    on: function (eventName, handler) {
        var m = this.eventMapping;
        if (m && m[eventName]) m[eventName].push(handler);
        return this
    },
    un: function (eventName, handler) {
        var m = this.eventMapping;
        if (m && m[eventName]) {
            if (!handler) {
                m[eventName] = [];
                return
            };
            var hs = m[eventName];
            for (var i = 0; i < m[eventName].length; i++) {
                if (m[eventName][i] === handler) m[eventName].splice(i, 1)
            }
        }
        return this
    },
    trigger: function (eventName) {
        var m = this.eventMapping;
        if (m && m[eventName]) {
            for (var i = 0; i < m[eventName].length; i++) m[eventName][i].apply(this, arguments)
        };
        return this
    }
}); (function ($) {
    form = {
        disable: function (fm) {
            $(fm).find(":input").each(function (i, n) {
                var tmp = $(n);
                tmp.attr('oldDisabled', tmp.attr('disabled'));
                tmp.attr('disabled', 'disabled')
            })
        },
        enable: function (fm) {
            $(fm).find(":input").each(function (i, n) {
                var tmp = $(n);
                if (!tmp.attr('oldDisabled')) tmp.removeAttr('disabled')
            })
        },
        ajax: function (fm, dataType, callback) {
            if (typeof dataType == 'function') callback = dataType;
            var f = $(fm);
            $.ajax({
                url: f.attr('action') || location.href,
                type: f.attr('method') || 'get',
                data: f.serialize(),
                cache: false,
                dataType: dataType,
                beforeSend: function () {
                    form.disable(fm)
                },
                success: function (res) {
                    form.enable(fm);
                    if (callback) callback(res)
                },
                error: function (res) {
                    form.enable(fm);
                    alert('对不起，服务发生错误。请稍候再试')
                }
            })
        },
        validBind: function (fm, fns) {
            fns = fns || {};
            var that = this;
            fm = $(fm).submit(function () {
                var pass = that.valid(fm, fns.errorFn);
                if (pass && fns.submitFn) return fns.submitFn(fm);
                return pass
            });
            fm.find(':input[dataType]').each(function (i, n) {
                $(n).focus(function () {
                    if (fns.focusFn) fns.focusFn(n)
                }).blur(function () {
                    if (that._checkInput(n,
                    function (msg) {
                        if (fns.errorFn) fns.errorFn(msg, n)
                    }) && fns.okFn) fns.okFn(n)
                })
            })
        },
        valid: function (fm, fn, focus) {
            var that = this;
            fm = $(fm);
            fn = fn || alert;
            var pass = true;
            fm.find(':input[dataType]').each(function (i, n) {
                var res = that._checkInput(n,
                function (msg) {
                    fn(msg, n);
                    if (focus) n.focus()
                });
                if (!res) pass = false;
                if (focus) return pass
            });
            return pass
        },
        _checkInput: function (n, fn) {
            with (n) {
                if (getAttribute('must') == 'false' && value == '') return true;
                var tp = getAttribute('dataType');
                if (tp) {
                    var s = tp.split('|');
                    for (var n = 0; n < s.length; n++) {
                        if (!(eval(this.validType[s[n]]))) {
                            var m = (getAttribute('msg') || '请输入正确数据').split('|');
                            fn(m[n] || m[0]);
                            return false
                        }
                    }
                }
                return true
            }
        },
        validType: {
            must: 'jQuery.trim(value) != (getAttribute("empty") || "")',
            number: '/^-?\\d+$/.test(value)',
            money: '/^-?\\d+(\\.\\d+)?$/.test(value)',
            email: '/^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/.test(value)',
            url: '/^http:\\/\\/[A-Za-z0-9]+\\.[A-Za-z0-9]+[\\/=\\?%\\-&_~`@[\\]\\\':+!]*([^<>\\"\\"])*$/.test(value)',
            zip: '/^[1-9]\\d{5}$/.test(value)',
            qq: '/^\\d{5,15}$/.test(value)',
            chinese: '/^[\\u0391-\\uFFE5]$/.test(value)',
            length: 'value.length >= (parseInt(getAttribute("min"),10)||0) && value.length <= (parseInt(getAttribute("max"),10)||9999999)',
            range: '(value||0) >= (parseInt(getAttribute("min"),10)||0) && (value||0) <= (parseInt(getAttribute("max"),10)||0)',
            custom: '(new RegExp(getAttribute("regexp"), "i")).test(value)',
            date: '(new RegExp(getAttribute("fmt") || "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$")).test(value)',
            ajax: 'this.validType._ajaxValid(getAttribute("url") || location.href, value)',
            same: 'value == document.getElementById(getAttribute("ref")).value',
            group: 'this.validType._checked(getAttribute("name"), getAttribute("min"), getAttribute("max"))',
            moreThan: '(parseInt($("#" + getAttribute("id")).val(),10) || 9999) >= (parseInt($("#" + getAttribute("ref")).val(),10) || 0)',
            _ajaxValid: function (url, val) {
                var res = true;
                $.ajax({
                    type: 'get',
                    url: url,
                    async: false,
                    cache: false,
                    data: {
                        data: val
                    },
                    error: function () {
                        alert('抱歉，远程通信发生错误，请稍候重试！');
                        res = false
                    },
                    success: function (result) {
                        res = result == 'ok'
                    }
                });
                return res
            },
            _checked: function (name, min, max) {
                var groups = document.getElementsByName(name);
                var hasChecked = 0;
                min = min || 1;
                max = max || groups.length;
                for (var i = groups.length - 1; i >= 0; i--) {
                    if (groups[i].tagName == "SELECT" && jQuery(groups[i]).val() != '') hasChecked++;
                    else if (groups[i].checked) hasChecked++
                }
                return min <= hasChecked && hasChecked <= max
            }
        }
    };
    $(function () {
        $('form.auto').live('submit',
        function () {
            var me = $(this);
            if (window.form.valid(this,
            function (msg) {
                new ui.Tips({
                    msg: msg,
                    ele: me.find('input[type="submit"]'),
                    type: 'error'
                })
            },
            true)) {
                window.form.ajax(this, 'json',
                function (r) {
                    if (r.Success) {
                        new ui.Tips({
                            msg: r.Message,
                            ele: me.find('input[type="submit"]'),
                            callback: function () {
                                var onsuccess = me.attr('onsuccess');
                                if (onsuccess) eval(onsuccess)
                            }
                        })
                    } else new ui.Tips({
                        msg: r.Message,
                        ele: me.find('input[type="submit"]'),
                        type: 'error'
                    })
                })
            }
            return false
        })
    })
})(jQuery); (function ($) {
    ui = {
        isIE: $.browser.msie,
        ie6: $.browser.msie && $.browser.version == '6.0',
        keyCode: {
            ALT: 18,
            BACKSPACE: 8,
            CONTROL: 17,
            DELETE: 46,
            DOWN: 40,
            END: 35,
            ENTER: 13,
            ESC: 27,
            HOME: 36,
            INSERT: 45,
            LEFT: 37,
            PAGE_DOWN: 34,
            PAGE_UP: 33,
            RIGHT: 39,
            SHIFT: 16,
            SPACE: 32,
            TAB: 9,
            UP: 38
        }
    };
    $.fn.clientSize = function () {
        var el = this[0];
        var isDoc = el === window || el === document || el === document.body;
        return {
            width: isDoc ? document.documentElement.clientWidth : el.clientWidth,
            height: isDoc ? document.documentElement.clientHeight : el.clientHeight
        }
    };
    $.fn.scrollInfo = function () {
        var dom = this[0];
        var isbody = (dom === document || dom === document.body);
        return {
            left: isbody ? (document.documentElement.scrollLeft || document.body.scrollLeft) : dom.scrollLeft,
            top: isbody ? (document.documentElement.scrollTop || document.body.scrollTop) : dom.scrollTop
        }
    };
    $.fn.fullSize = function () {
        var dom = this[0],
        w,
        h;
        if (dom === document || dom === document.body || dom == document.documentElement) {
            w = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth, document.documentElement.clientWidth);
            h = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight, document.documentElement.clientHeight)
        } else {
            w = dom.offsetWidth;
            h = dom.offsetHeight
        }
        return {
            width: w,
            height: h
        }
    };
    $.fn.center = function (container) {
        if (this.length == 0) return this;
        var ct = $(container || document.body);
        var isbody = ct[0] === document || ct[0] === document.body;
        var ctSroll = ct.scrollInfo();
        var ctSize = isbody ? ct.clientSize() : ct.fullSize();
        var that = this;
        return this.each(function (i, n) {
            var obj = $(n);
            var size = obj.fullSize();
            var scroll = (obj.css('position') == 'fixed') ? {
                left: 0,
                top: 0
            } : ctSroll;
            obj.css({
                left: (ctSize.width - size.width) / 2 + scroll.left,
                top: (ctSize.height - size.height) / 2 + scroll.top
            })
        })
    };
    $.fn.shadow = function () {
        return this.each(function (i, n) {
            var obj = $(n);
            $(obj).css({
                '-webkit-box-shadow': '1px 2px 5px #666',
                '-moz-box-shadow': '1px 2px 5px #666',
                'filter': obj.css('filter') + ' ' + 'progid:DXImageTransform.Microsoft.Shadow(color=#aaaaaa,direction=145,strength=3)',
                'zoom': '1'
            })
        })
    };
    $.fn.opacity = function (value) {
        return this.each(function (i, n) {
            var obj = $(n);
            $(obj).css({
                'opacity': value,
                '-moz-opacity': value,
                'filter': obj.css('filter') + ' ' + 'alpha(opacity=' + (value * 100) + ')'
            })
        })
    };
    $.fn.bgiframe = (ui.ie6) ?
    function () {
        var html = '<iframe class="bgiframe" style="display:block;position:absolute;z-index:-1;_filter:alpha(opacity=\'0\');_top:expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\');_left:expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\');_width:expression(this.parentNode.offsetWidth+\'px\');_height:expression(this.parentNode.offsetHeight+\'px\');" frameborder="0" tabindex="-1" src=""></iframe>';
        return this.each(function () {
            if ($(this).children('iframe.bgiframe').length == 0) {
                this.insertBefore(document.createElement(html), this.firstChild)
            }
        })
    } : function () {
        return this
    };
    ui.ObjectBase = ObjectBase.extend({
        init: function (options, scope) {
            (function () {
                this.regEvent('destroy');
                this.els = {};
                this.fns = {}
            }).call(scope || this);
            this.base.init.call(this.base, options, scope || this);
            return this
        },
        destroy: function () {
            for (var s in this.els) {
                $(this.els[s]).remove()
            }
            this.trigger('destroy')
        }
    })
})(jQuery); (function ($, ns) {
    ns.Mask = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                el: document.body,
                bgColor: '#000',
                opacity: 0.2,
                zIndex: 1,
                anima: true
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            var div = this.els['maskDiv'] = $('<div style="position:absolute;z-index:{0};background-color:{1};display:none;"></div>'.format(options.zIndex, options.bgColor)).opacity(options.opacity).bgiframe();
            this.initMaskSize();
            $(options.el).append(div);
            options.anima ? div.fadeIn('fast') : div.show();
            this.bindEvent();
            return this
        },
        initMaskSize: function () {
            var div = this.els['maskDiv'];
            var el = $(this.options.el);
            var size = el.fullSize();
            var pos = (el.css('position') == 'relative') ? {
                left: 0,
                top: 0
            } : el.position();
            var leftBorder = parseInt(el.css('border-left-width')) || 0;
            var rightBorder = parseInt(el.css('border-right-width')) || 0;
            var topBorder = parseInt(el.css('border-top-width')) || 0;
            var bottomBorder = parseInt(el.css('border-bottom-width')) || 0;
            div.css({
                left: pos.left,
                top: pos.top,
                width: size.width - (leftBorder + rightBorder),
                height: size.height - (topBorder + bottomBorder)
            });
            return this
        },
        bindEvent: function () {
            var dom = $(this.options.el)[0];
            var isbody = (dom === document || dom === document.body);
            if (isbody) {
                var that = this;
                this.fns['windowResize'] = function () {
                    that.initMaskSize()
                };
                $(window).resize(this.fns['windowResize'])
            }
            return this
        },
        destroy: function () {
            $(window).unbind('resize', this.fns['windowResize']);
            this.base.destroy.call(this)
        }
    });
    $.fn.mask = function (options) {
        options = options || {};
        return this.each(function (i, n) {
            new ns.Mask($.extend(options, {
                el: n
            }))
        })
    }
})(jQuery, ui); (function ($, ns) {
    ns.Tips = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                type: 'success',
                msg: '',
                ele: document.body,
                anima: 1500,
                callback: null
            },
            options);
            if (!options.msg) return;
            var dom = $('<div class="ui-tips"><p class="{0}">{1}</p></div>'.format(options.type, options.msg));
            dom.appendTo(document.body);
            var pos;
            if (options.ele == document.body) {
                dom.center();
                pos = dom.position()
            } else {
                var ele = $(options.ele);
                pos = ele.offset();
                var eleW = $(options.ele).width();
                var domW = dom.fullSize().width;
                if (eleW > domW) {
                    pos.left += ((eleW - domW) / 2)
                }
                dom.css({
                    left: pos.left,
                    top: pos.top
                })
            }
            dom.animate({
                top: pos.top - 60
            },
            100,
            function () {
                setTimeout(function () {
                    dom.animate({
                        top: pos.top - 200,
                        opacity: 'hide'
                    },
                    options.anima,
                    function () {
                        dom.remove();
                        if (options.callback) options.callback()
                    })
                },
                1000)
            });
            this.base.init.call(this.base, options, scope || this)
        }
    })
})(jQuery, ui); (function ($, ns) {
    ns.Dialog = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                width: 500,
                height: 300,
                borderColor: '#b1d85c',
                title: '',
                modal: true,
                zIndex: 2,
                url: '',
                html: '',
                waitImg: '/Images/loading32.gif'
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            var dom = this.createDom();
            var body = dom.find('.ui-dialogBody');
            var h = options.height - dom.find('.ui-dialogTitle').height();
            body.height(h);
            if (options.url) {
                var waiting = $('<div style="width:100%; height:' + h + 'px;"><img style="position:absolute;" src="' + options.waitImg + '" alt="" title="加载中..." /></div>');
                var frame = $('<iframe frameborder="0" width="100%" style="display:none;" height="' + h + 'px" src=""></iframe>');
                frame.bind('load',
                function () {
                    frame.show();
                    waiting.remove()
                });
                body.append(waiting);
                waiting.find('img').center(waiting);
                body.append(frame);
                frame.attr('src', options.url)
            } else if (options.html) body.html(options.html);
            if (options.modal) this.mask = new ns.Mask({
                zIndex: options.zIndex - 1
            });
            this.bindEvent();
            return this
        },
        createDom: function () {
            this.els['dom'] = $('<div class="ui-dialog">' + (this.options.title ? '<div class="ui-dialogTitle" unselectable="on" onselectstart="return false;">' + '<a class="ui-dialogClose" title="关闭" href="javascript:">X</a>' + '<h1>' + this.options.title + '</h1>' + '</div>' : '<a class="ui-dialogClose ui-notitle" title="关闭" href="javascript:">X</a>') + '<div class="ui-dialogBody"></div>' + '</div>').css({
                'width': this.options.width + 'px',
                'height': this.options.height + 'px',
                'z-index': this.options.zIndex,
                'border-color': this.options.borderColor
            }).appendTo(document.body).center().shadow();
            return this.els['dom']
        },
        bindEvent: function () {
            var that = this;
            this.els['dom'].find('.ui-dialogClose').click(function () {
                that.destroy()
            });
            if (this.options.url && this.options.drag) {
                var iframeMask;
                this.drag.on('start',
                function () {
                    iframeMask = new ns.Mask({
                        el: that.els['dom'].find('.ui-dialogBody'),
                        opacity: 1,
                        bgColor: '#fff',
                        anima: false
                    })
                }).on('end',
                function () {
                    iframeMask.destroy()
                })
            }
            var escFun = function (event) {
                if (event.keyCode == ui.keyCode.ESC) {
                    that.destroy();
                    $(document).unbind('keyup', escFun)
                }
            };
            $(document).bind('keyup', escFun);
            return this
        },
        destroy: function () {
            if (this.mask) this.mask.destroy();
            if (this.drag) this.drag.destroy();
            this.base.destroy.call(this)
        }
    })
})(jQuery, ui); (function ($, ns) {
    ns.Tabs = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                tabSelector: '>dt a',
                selectedClass: 'on',
                event: 'click'
            },
            options);
            this.regEvent('swich');
            this.base.init.call(this.base, options, scope || this);
            var dom = $(options.el);
            var tabs = this.tabs = dom.find(options.tabSelector);
            this.bindEvent();
            if (location.hash) {
                tabs.filter('[href="' + location.hash + '"]').trigger(this.options.event)
            } else if (tabs.length) {
                $(tabs[0]).trigger(this.options.event)
            }
            return this
        },
        swich: function (hash) {
            if (hash.startWith('#')) {
                var selctedcls = this.options.selectedClass;
                this.tabs.each(function (i, n) {
                    n = $(n);
                    var href = n.attr('href');
                    if (href == hash) {
                        n.addClass(selctedcls);
                        $(href).show()
                    } else {
                        n.removeClass(selctedcls);
                        $(href).hide()
                    }
                });
                this.trigger('swich', hash)
            }
            return this
        },
        bindEvent: function () {
            var that = this;
            this.fns['tabClick'] = function () {
                that.swich($(this).attr('href'));
                return false
            };
            this.tabs.bind(this.options.event, this.fns['tabClick']);
            return this
        },
        destroy: function () {
            this.tabs.unbind(this.options.event, this.fns['tabClick']);
            this.base.destroy.call(this)
        }
    });
    $.fn.tabs = function (options) {
        options = options || {};
        return this.each(function (i, n) {
            new ns.Tabs($.extend(options, {
                el: n
            }))
        })
    };
    $(function () {
        $('.ui-tab').tabs()
    })
})(jQuery, ui); (function ($, ns) {
    ns.LazyLoad = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                initFn: emptyFn,
                renderFn: emptyFn
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            this.el = $(options.el);
            this.el.each(function (i, n) {
                options.initFn(n)
            });
            this.bindEvent();
            return this
        },
        bindEvent: function () {
            var that = this;
            this.fns['handler'] = function () {
                var pageHeight = $(document).clientSize().height;
                var pageTop = pageHeight + Math.max(document.documentElement.scrollTop, document.body.scrollTop);
                that.el.each(function (i, n) {
                    if (!n.rendered) {
                        var obj = $(n);
                        if (obj.offset().top <= pageTop) {
                            n.rendered = true;
                            that.options.renderFn(n)
                        }
                    }
                })
            };
            $(window).bind('load scroll resize', this.fns['handler']);
            return this
        },
        destroy: function () {
            $(window).unbind('load scroll resize', this.fns['handler']);
            this.base.destroy.call(this)
        }
    });
    $.fn.lazyLoad = function (options) {
        options = options || {};
        return new ns.LazyLoad($.extend(options, {
            el: this
        }))
    };
    $(function () {
        $('.dhp .pic img').lazyLoad({
            renderFn: function (n) {
                n = $(n);
                n.attr('src', n.attr('oldsrc')).removeAttr('oldsrc')
            }
        })
    })
})(jQuery, ui); (function ($, ns) {
    ns.Suggest = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                delay: 200,
                url: '',
                cls: 'suggest-result',
                selectClass: 'selected',
                minchars: 1,
                delimiter: '\n',
                idDelimiter: ','
            },
            options);
            scope = scope || this;
            this.base.init.call(this.base, options, scope);
            this.selectIndex = -1;
            this.selectItems = null;
            this.currentKey = null;
            this.isShow = false;
            this.createDom.call(scope);
            this.bindEvent.call(scope);
            return this
        },
        createDom: function () {
            this.els['dom'] = $('<div class="' + this.options.cls + '"></div>').mousedown(function () {
                return false
            }).appendTo(document.body)
        },
        bindEvent: function () {
            var that = this,
            op = this.options,
            el = $(op.el);
            var timer = null;
            el.bind('keyup',
            function (event) {
                if (timer) clearTimeout(timer);
                var delay = op.delay;
                switch (event.keyCode) {
                    case ui.keyCode.UP:
                        that.prev();
                        return;
                    case ui.keyCode.ESC:
                        $(that.options.el).val(that.currentKey);
                        if (that.options.idEl) $(that.options.idEl).val('');
                        that.hideResult();
                        return;
                    case ui.keyCode.DOWN:
                        if (that.els['dom'].css('display') != 'none') {
                            that.next();
                            return
                        }
                        delay = 0;
                        break;
                    case ui.keyCode.ENTER:
                    case ui.keyCode.LEFT:
                    case ui.keyCode.RIGHT:
                        break;
                    default:
                        if (that.options.idEl) $(that.options.idEl).val('')
                }
                var val = el.val();
                if (val.length >= op.minchars) {
                    timer = setTimeout(function () {
                        that.getResult(val)
                    },
                    delay)
                } else {
                    that.hideResult()
                }
                return false
            }).bind('keydown',
            function (e) {
                if (event.keyCode == ui.keyCode.TAB) that.hideResult()
            });
            return this
        },
        getResult: function (val) {
            var that = this,
            op = this.options;
            var el = $(op.el),
            dom = this.els['dom'];
            var key = el.val();
            if (key == val) {
                if (val == this.currentKey) {
                    that.showResult();
                    return
                }
                $.ajax({
                    url: op.url,
                    data: {
                        key: key
                    },
                    beforeSend: function () {
                        dom.empty()
                    },
                    success: function (res) {
                        if (val == el.val()) {
                            var rs = res.split(op.delimiter);
                            var html = [];
                            for (var i = 0; i < rs.length; i++) {
                                var s = rs[i];
                                if (s && s != '') {
                                    var idValue = '',
                                    title = '',
                                    text = '';
                                    var splits = s.split(that.options.idDelimiter);
                                    if (splits.length == 1) text = splits[0];
                                    else if (splits.length == 2) {
                                        title = splits[0];
                                        text = splits[1]
                                    } else if (splits.length == 3) {
                                        idValue = splits[0];
                                        title = splits[1];
                                        text = splits[2]
                                    }
                                    html.push('<li idValue="' + idValue + '" title="' + title + '">' + text + '</li>')
                                }
                            }
                            if (html.length > 0) {
                                html = '<ul>' + html.join('') + '</ul>';
                                dom.html(html);
                                that.selectIndex = -1;
                                that.selectItems = dom.find('ul li').mouseover(function () {
                                    that.selectIndex = that.selectItems.index(this);
                                    that.selectItem()
                                })
                            } else {
                                html = '<p>未找到<strong>' + val + '</strong>的相关信息</p>';
                                dom.html(html)
                            }
                            var tmp = $('<div class="' + op.cls + '"></div>').html(html).appendTo(document.body);
                            var width = tmp.outerWidth();
                            tmp.remove();
                            var pos = el.offset();
                            dom.css({
                                'left': pos.left,
                                'top': pos.top + el[0].offsetHeight,
                                'width': Math.max(el[0].offsetWidth - 1, width)
                            });
                            that.showResult();
                            that.currentKey = val
                        }
                    }
                })
            }
            return this
        },
        hideResult: function () {
            this.els['dom'].hide();
            this.isShow = false
        },
        showResult: function () {
            var that = this;
            if (!this.isShow) {
                this.isShow = true;
                this.els['dom'].show();
                $(document).one('mousedown',
                function (event) {
                    that.hideResult()
                })
            }
        },
        prev: function () {
            if (this.selectIndex > 0) this.selectIndex--;
            else this.selectIndex = this.selectItems.length - 1;
            this.selectItem();
            return false
        },
        next: function () {
            this.showResult();
            if (this.selectItems.length > this.selectIndex + 1) this.selectIndex++;
            else this.selectIndex = 0;
            this.selectItem();
            return false
        },
        selectItem: function () {
            var items = this.selectItems;
            var selectCls = this.options.selectClass;
            if (items) {
                if (items.length < this.selectIndex + 1) return;
                var selected = items.removeClass(selectCls).eq(this.selectIndex);
                selected.addClass(selectCls);
                var val = selected.attr('title');
                $(this.options.el).val(val);
                this.currentKey = val;
                if (this.options.idEl) $(this.options.idEl).val(selected.attr('idValue'));
                var sel = items.eq(this.selectIndex)
            }
        }
    })
})(jQuery, ui); (function ($, ns) {
    ns.Focus = ns.ObjectBase.extend({
        init: function (options, scope) {
            this.base.init.call(this.base, options, scope || this);
            var el = this.el = $(options.el),
            that = this;
            this.ps = $('dd p', el);
            this.animas = $('dd p, dd p span, dd p a.more', el);
            this.titles = $('dt a', el).mouseover(function () {
                that.animas.stop(true, true);
                that.swich(that.titles.index(this))
            });
            var autoHd;
            var setAuto = function () {
                autoHd = setInterval(function () {
                    var index = that.current + 1;
                    if (that.titles.length <= index) index = 0;
                    that.swich(index)
                },
                5000)
            };
            el.hover(function () {
                clearInterval(autoHd)
            },
            setAuto);
            this.swich(0);
            setAuto();
            return this
        },
        swich: function (index) {
            this.current = index;
            var ts = this.titles,
            ps = this.ps;
            ts.filter('.on').removeClass('on');
            ts.eq(index).addClass('on');
            function show() {
                var p = ps.eq(index);
                var span = $('span', p).css('top', '260px');
                var more = $('a.more', p).hide();
                p.fadeIn('2000',
                function () {
                    span.animate({
                        top: '176px'
                    },
                    'slow',
                    function () {
                        more.fadeIn('slow')
                    })
                })
            }
            ps.filter(':visible').fadeOut('2000');
            show()
        }
    })
})(jQuery, ui); (function ($, ns) {
    ns.Rate = ns.ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                level: ['垃圾', '较差', '一般', '好看', '神作'],
                url: '/Video/Ajax.aspx?action=rate&Id=' + options.flag
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            this.el = $(options.el);
            this.initEvent();
            return this
        },
        initEvent: function () {
            var that = this;
            var el = this.el,
            star = el.children('.star'),
            stars = star.children('i'),
            starTxt = el.children('.star-text');
            var outFn = function () {
                stars.each(function (i, n) {
                    n.className = ''
                });
                starTxt.empty()
            };
            star.mouseout(outFn);
            var overFn = function () {
                var me = $(this);
                var idx = stars.index(this);
                stars.each(function (i, n) {
                    n.className = i > idx ? '' : (idx > 1 ? 'up' : 'low')
                });
                starTxt.html(me.html())
            };
            var clickFn = function () {
                if (window.name == that.options.flag) {
                    starTxt.html('已经评过分啦');
                    return
                }
                var idx = stars.index(this);
                starTxt.html('已评分(<span style="color:#aaa;">' + that.options.level[idx] + '</span>)');
                star.unbind('mouseout', outFn);
                stars.unbind('mouseover', overFn).unbind('click', clickFn);
                $.ajax({
                    dataType: 'json',
                    url: that.options.url,
                    data: {
                        rate: idx + 1
                    },
                    cache: false,
                    success: function (res) {
                        that.update(res);
                        window.name = that.options.flag
                    }
                })
            };
            stars.mouseover(overFn).click(clickFn)
        },
        update: function (data) {
            var score = data.score.split('.');
            var max = Math.max.apply(Math, data.detail);
            function getIWidth(v) {
                return max > 0 ? (120 * v / max).toFixed(0) : 0
            };
            var html = ['<dt><strong><em>' + score[0] + '</em>.' + score[1] + '</strong> 分 / <span>' + eval(data.detail.join('+')) + '</span> 人参与评分</dt>'];
            for (var i = this.options.level.length - 1; i >= 0; i--) {
                html.push('<dd><label>' + this.options.level[i] + '：</label><i style="width:' + getIWidth(data.detail[i]) + 'px;"></i> ' + data.detail[i] + '人</dd>')
            };
            this.el.children('dl').html(html.join(''))
        }
    })
})(jQuery, ui);
utils.ns('dhp'); (function ($, ns) {
    ns.Player = ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                width: '980px',
                height: '520px',
                loadingPage: '/XiuShen/XiuShen/Loading'
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            this.el = $(options.el);
            this.ctr = this.el.parent();
            return this
        },
        play: function (site, vars) {
            var that = this;
            var ops = this.options;
            this.el.html('<iframe scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" src="' + ops.loadingPage + '"></iframe>');
            setTimeout(function () {
                var notSupport = '<iframe scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" src="' + ops.loadingPage + '?notsupport"></iframe>';
                if (that.site[site]) {
                    if (that.supportFlash()) that.site[site].call(that, vars);
                    else if (that.supportVideo()) {
                        $.get('/Video/3G.aspx', {
                            id: vars,
                            player: site
                        },
                        function (res) {
                            if (res.Success) that.el.html('<video src="' + res.Message + '" controls="controls" autoplay="autoplay" width="' + ops.width + '" height="' + ops.height + '"></video>');
                            else that.el.html(notSupport)
                        },
                        'json')
                    } else that.el.html(notSupport)
                }
            },
            3000)
        },
        supportFlash: function () {
            return swfobject.getFlashPlayerVersion().major != 0
        },
        supportVideo: function () {
            return !!document.createElement('video').canPlayType
        },
        site: {
            tudou: function (v) {
                var that = this;
                this.renderSwf('http://img.58dm.com/Player/TudouVideoPlayer_Homer_NewSkin_27.swf', {
                    iid: v,
                    listType: '2',
                    default_skin: '1',
                    tudouMini: '0',
                    hd: '2',
                    isRec: '1',
                    ports: '100:0',
                    statratio: '1000',
                    safekey: 'IAlsoNeverKnow',
                    theme: 'black',
                    cs: '350',
                    ct: '180',
                    ca: '0',
                    cb: '0.1',
                    cp: '20',
                    nc: '0',
                    actionID: '1',
                    adOwnerId: '0',
                    adPositionId: '0',
                    isNielson: '0',
                    isRenhe: '0',
                    phd: '-1',
                    csc6: '0',
                    nls: '0',
                    np: '0',
                    nm: '0',
                    scale: '1'
                });
                window.playerEx = {
                    notify: function () {
                        if (arguments.length > 1 && arguments[1] == 'recommend') {
                            if (that.supportAutoNext('tudou')) that.autoNext()
                        }
                    }
                }
            },
            youku: function (v) {
                this.renderSwf('http://static.youku.com/v1.0.0098/v/swf/qplayer_taobao.swf', {
                    VideoIDS: v,
                    isAutoPlay: true,
                    showAd: 0,
                    Version: "/v1.0.0654",
                    winType: "interior"
                });
                this.nextBind('youku', 'onPlayerComplete')
            },
            youku_hd: function (v) {
                this.renderSwf('http://static.youku.com/v1.0.0210/v/swf/player.swf', {
                    VideoIDS: v,
                    isAutoPlay: true,
                    showAd: 0,
                    Version: "/v1.0.0654",
                    winType: "interior"
                });
                this.nextBind('youku_hd', 'onPlayerComplete')
            },
            _56: function (v) {
                this.renderSwf('http://www.56.com/flashApp/v_player.12.04.10.swf', {
                    vid: v,
                    effectID: 0
                },
                {
                    allowNetworking: 'internal'
                });
                this.nextBind('_56', 's2j_onPlayOver')
            },
            cntv: function (v) {
                this.renderSwf('http://img.58dm.com/Player/cntvplayer.swf?v=0.171.5.8.5.9.9', {
                    videoCenterId: v,
                    videoId: '20110711'
                });
                this.nextBind('cntv', 'video_play_over')
            },
            ku6: function (v) {
                this.renderSwf('http://player.ku6cdn.com/default/out/pV2.7.7.swf', {
                    vid: v,
                    auto: '1',
                    deflogo: '0',
                    so: '0',
                    jump: '0',
                    pv: '0',
                    api: '1'
                });
                this.nextBind('ku6', 'playFinish')
            },
            sina: function (v) {
                this.renderSwf('http://p.you.video.sina.com.cn/swf/tvPlayer20120331_V4_2_39_38.swf', {
                    vid: v,
                    autoPlay: '1',
                    actlogActive: '0'
                });
                this.nextBind('sina', 'nextPlay')
            },
            qiyi: function (v) {
                this.renderSwf('http://www.qiyi.com/player/20110804140023/qiyi_n_player.swf', {
                    vid: v,
                    preLoaderUrl: 'http://www.qiyi.com/player/20110323181221/preloader.swf'
                });
                this.nextBind('qiyi', 'videoPlayEnd')
            },
            letv: function (v) {
                var that = this;
                this.renderSwf('http://img.58dm.com/Player/letvPlayer.swf', {
                    id: v,
                    autoplay: '1',
                    typeFrom: '163',
                    pltype: 1,
                    plugins: 'http://player.letvcdn.com/p/201204/13/player/hlg/plugins/displayBar.swf',
                    hintFile: 'http://player.letvcdn.com/p/201203/29/player/hlg/plugins/Hint.swf',
                    topFile: 'http://player.letvcdn.com/p/201203/29/player/hlg/plugins/TopBtn.swf'
                });
                setTimeout(function () {
                    that.nextBind('letv', 'flashNextHandler')
                },
                30000)
            },
            qq: function (v) {
                this.renderSwf('http://static.video.qq.com/TencentPlayer.swf', {
                    vid: v,
                    version: '20110401',
                    autoplay: '1',
                    list: '2'
                });
                this.nextBind('qq', 'nextplay')
            },
            qqold: function (v) {
                this.renderSwf('http://mat1.qq.com/news/act3/js/QQPlayer3.swf', {
                    vid: v,
                    skin: 'http://mat1.qq.com/news/act3/js/skins/QQPlayerSkin.swf',
                    autoplay: '1'
                })
            },
            sohu: function (v) {
                this.renderSwf('http://share.vrs.sohu.com/' + v + '/v.swf&autoplay=true');
                this.nextBind('sohu', 'swfGotoNewPage')
            },
            baidu: function (v) {
                var ops = this.options;
                if (ui.isIE) {
                    this.el.html('<iframe id="baiduInstall" name="baiduInstall" scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" style="display: none;" src=""></iframe>' + '<object classid="clsid:02E2D748-67F8-48B4-8AB4-0A085374BB99" width="' + ops.width + '" height="' + ops.height + '" id="baiduPlayer" name="baiduPlayer" onerror="document.getElementById(\'baiduPlayer\').style.display=\'none\';document.getElementById(\'baiduInstall\').style.display=\'\';document.getElementById(\'baiduInstall\').src=\'http://player.baidu.com/lib/install/\';">' + '<param name="URL" value="' + v + '">' + '<param name="Autoplay" value="1">' + '<param name="Buffer" value="' + ops.loadingPage + '">' + '<param name="Pause" value="' + ops.loadingPage + '?end">' + '<param name="End" value="' + ops.loadingPage + '?end">' + '<param name="NextWebPage" value="' + playerInfo.nextPage + '">' + '<param name="LastWebPage" value="' + playerInfo.prevPage + '">' + '</object>')
                } else {
                    if (this.checkPlugin('BaiduPlayer Browser Plugin')) {
                        this.el.html('<object id="baiduPlayer" name="baiduPlayer" type="application/player-activex" width="' + ops.width + '" height="' + ops.height + '" progid="Xbdyy.PlayCtrl.1" param_URL="' + v + '" param_Autoplay="1" param_Buffer="' + ops.loadingPage + '" param_Pause="' + ops.loadingPage + '?end" param_End="' + ops.loadingPage + '?end" param_NextWebPage="' + playerInfo.nextPage + '" param_LastWebPage="' + playerInfo.prevPage + '"></object>')
                    } else {
                        this.el.html('<iframe id="baiduInstall" name="baiduInstall" scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" src="http://player.baidu.com/lib/install/"></iframe>')
                    }
                }
            },
            qvod: function (v) {
                var ops = this.options;
                if (ui.isIE) {
                    this.el.html('<iframe id="qvodInstall" name="qvodInstall" scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" style="display: none;" src=""></iframe>' + '<object classid="clsid:F3D0D36F-23F8-4682-A195-74C92B03D4AF" width="' + ops.width + '" height="' + ops.height + '" id="qvodPlayer" name="qvodPlayer" onerror="document.getElementById(\'qvodPlayer\').style.display=\'none\';document.getElementById(\'qvodInstall\').style.display=\'\';document.getElementById(\'qvodInstall\').src=\'http://error2.qvod.com/error4.htm\';">' + '<param name="Showcontrol" value="1">' + '<param name="URL" value="' + v + '">' + '<param name="AutoPlay" value="1">' + '<param name="QvodAdUrl" value="' + ops.loadingPage + '">' + '</object>')
                } else {
                    if (this.checkPlugin('QvodInsert')) {
                        this.el.html('<embed id="QvodPlayer2" name="QvodPlayer2" width="' + ops.width + '" height="' + ops.height + '" URL="' + v + '" type="application/qvod-plugin" Autoplay="1" QvodAdUrl="' + ops.loadingPage + '" Showcontrol="1"></embed>')
                    } else {
                        this.el.html('<iframe id="qvodInstall" name="qvodInstall" scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" src="http://error2.qvod.com/error4.htm"></iframe>')
                    }
                }
            }
        },
        renderSwf: function (url, vars, pams) {
            var ops = this.options;
            swfobject.embedSWF(url, this.el.attr('id'), ops.width, ops.height, "9.0.0", null, vars, $.extend({
                quality: "high",
                allowScriptAccess: "always",
                bgcolor: "#000000",
                allowfullscreen: "true",
                allowNetworking: "all",
                wmode: "transparent"
            },
            pams))
        },
        autoNextStatus: function (yes) {
            if (typeof yes == 'undefined') {
                var s = utils.cookie('autoNext');
                return s != 'false'
            }
            utils.cookie('autoNext', yes ? 'true' : 'false', {
                expires: 30,
                path: '/'
            })
        },
        nextBind: function (site, fun) {
            var that = this;
            window[fun] = function () {
                if (that.supportAutoNext(site)) that.autoNext()
            }
        },
        autoNext: function () {
            if (this._nextJump !== true && this.autoNextStatus() && playerInfo && playerInfo.nextPage != '') {
                this._nextJump = true;
                var ops = this.options;
                this.ctr.html('<iframe scrolling="no" frameborder="0" width="' + ops.width + '" height="' + ops.height + '" src="' + ops.loadingPage + '?next"></iframe>');
                setTimeout(function () {
                    location.href = playerInfo.nextPage + '?s=' + $(document).scrollTop()
                },
                3000)
            }
        },
        supportAutoNext: function (site) {
            var supports = {
                tudou: true,
                youku: true,
                youku_hd: true,
                letv: true,
                qiyi: true,
                _56: true,
                cntv: true,
                ku6: true,
                sina: true,
                qq: true,
                sohu: true
            };
            return supports[site] ? true : false
        },
        checkPlugin: function (name) {
            var plugs = navigator.plugins;
            if (plugs) {
                for (var i = 0; i < plugs.length; i++) {
                    if (plugs[i].name == name) return true
                }
            }
            return false
        }
    })
})(jQuery, dhp); (function ($, ns) {
    ns.History = ObjectBase.extend({
        init: function (options, scope) {
            options = $.extend({
                cookieName: 'his',
                max: 10
            },
            options);
            this.base.init.call(this.base, options, scope || this);
            return this
        },
        set: function (id, name, set, videoUrl, setUrl, lastAt) {
            var data = this.getValue();
            for (var i = 0; i < data.length; i++) {
                if (data[i].id == id) {
                    data.splice(i, 1);
                    break
                }
            }
            if (data.length >= this.options.max) data.splice(data.length - 1, 1);
            data.splice(0, 0, {
                id: id,
                name: name,
                set: set,
                videoUrl: videoUrl,
                setUrl: setUrl,
                lastAt: lastAt
            });
            return this.setValue(data)
        },
        remove: function (id) {
            var data = this.getValue();
            for (var i = 0; i < data.length; i++) {
                if (data[i].id == id) {
                    data.splice(i, 1);
                    return this.setValue(data)
                }
            }
            return this
        },
        clear: function () {
            this.setValue([]);
            return this
        },
        getValue: function () {
            var str = utils.cookie(this.options.cookieName);
            var hasv = (str && str != '');
            var data;
            if (hasv) {
                eval('data = ' + str);
                data = data.data
            } else data = [];
            return data
        },
        setValue: function (obj) {
            utils.cookie(this.options.cookieName, utils.toJsonString({
                data: obj
            }), {
                expires: 30,
                path: '/'
            });
            return this
        }
    });
    $(function () {
        var his = window.historyManager = new dhp.History();
        var data = his.getValue();
        var box = $('#historyBox').empty();
        if (box.length > 0) {
            if (data.length == 0) {
                box.append('<li>暂无记录</li>');
                return
            }
            for (var i = 0; i < data.length; i++) {
                var obj = data[i];
                box.append(['<li>', '<span class="fr">[<a href="' + obj.setUrl + '" class="green">' + obj.set + '</a>]</span>', '<a href="javascript:" onclick="window.historyManager.remove(\'' + obj.id + '\');$(this).closest(\'li\').remove();if($(\'#historyBox li\').length == 0) $(\'#historyBox\').append(\'<li>暂无记录</li>\');return false;" class="del gray" title="删除">X</a> ', '<a href="' + obj.videoUrl + '">' + obj.name + '</a>', '<p class="gray">上次于 ' + obj.lastAt + ' 观看</p>', '</li>'].join(''))
            }
        }
    })
})(jQuery, dhp);
var site = {
    m: function (name, style, mask) {
        document.write('<div style="' + style + '"><iframe frameborder="0" scrolling="no" src="/m.aspx?name=' + name + (mask ? '&mask=true' : '') + '" width="100%" height="100%"></iframe></div>')
    },
    count: function (id, type) {
        if (type) {
            var url = '/' + type + '/Ajax.aspx?action=count&Id=' + id;
            $.ajax({
                cache: false,
                url: url
            })
        }
    },
    qqshare: function () {
        document.write('<a version="1.0" class="qzOpenerDiv" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_likeurl" target="_blank"></a><script  src="http://qzonestyle.gtimg.cn/qzone/app/qzlike/qzopensl.js#jsdate=20111107&style=2&showcount=1&width=130&height=30" charset="utf-8" defer="defer" ></script>')
    },
    attention: function () { },
    emailLogin: {
        data: {
            '163.com': 'http://mail.163.com/',
            'qq.com': 'http://mail.qq.com/',
            'sina.com': 'http://mail.sina.com/',
            'yahoo.com': 'https://mail.yahoo.com/',
            'yahoo.cn': 'https://mail.yahoo.cn/',
            'sohu.com': 'http://mail.sohu.com/',
            'yeah.net': 'http://mail.yeah.net/',
            '139.com': 'http://mail.139.com/',
            'tom.com': 'http://mail.tom.com/'
        },
        getUrl: function (email) {
            if (!email) return '';
            var doman = email.substring(email.indexOf('@') + 1);
            if (site.emailLogin.data[doman]) return site.emailLogin.data[doman];
            else return 'http://www.' + doman
        }
    },
    fav: {
        add: function (id, callback) {
            var url = '/Video/Ajax.aspx?action=addFav&Id=' + id;
            callback = callback || emptyFn;
            $.ajax({
                cache: false,
                url: url,
                dataType: 'json',
                success: function (res) {
                    if (res.Success) {
                        new ui.Tips({
                            msg: '收藏成功',
                            ele: '.fav'
                        });
                        callback()
                    } else {
                        site.user.login.open(function () {
                            site.fav.add(id);
                            callback()
                        })
                    }
                }
            })
        },
        set: function (id, player, set) {
            var url = '/Video/Ajax.aspx?action=setFav&Id=' + id + '&player=' + player + '&set=' + set;
            $.ajax({
                cache: false,
                url: url
            })
        }
    },
    user: {
        login: {
            win: null,
            callback: null,
            open: function (callbak) {
                site.user.login.callback = function () {
                    site.user.login.close();
                    utils.loadResource('script', '/User/UserStatus.aspx?' + Math.random());
                    if (callbak) callbak()
                };
                site.user.login.win = new ui.Dialog({
                    url: '/User/LoginMin.aspx',
                    zIndex: 10
                });
                return false
            },
            close: function () {
                site.user.login.win.destroy()
            }
        },
        oauth: {
            win: null,
            open: function (link) {
                site.user.oauth.win = window.open(link, 'oauth', 'width=500,height=380,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1');
                return false
            },
            close: function () {
                if (site.user.oauth.win) site.user.oauth.win.close()
            }
        },
        status: function () {
            document.write('<script type="text/javascript" src="/User/UserStatus.aspx?' + Math.random() + '"></script>')
        }
    }
};